package com.ruoyi.datam.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.datam.service.IStStationBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.domain.base.datam.StStationB;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 测站信息登记Controller
 *
 * @author hwd
 * @date 2023-02-16
 */
@RestController
@RequestMapping("/StStationB")
public class StStationBController extends BaseController
{
    @Autowired
    private IStStationBService stStationBService;

    /**
     * 查询测站信息登记列表
     */
    @RequiresPermissions("datam:StStationB:list")
    @GetMapping("/list")
    public TableDataInfo list(StStationB stStationB)
    {
        startPage();
        List<StStationB> list = stStationBService.selectStStationBList(stStationB);
        return getDataTable(list);
    }

    /**
     * 查询测站信息登记列表
     */
    @RequiresPermissions("datam:StStationB:list")
    @GetMapping("/AllList")
    public TableDataInfo AllList(StStationB stStationB)
    {

        List<StStationB> list = stStationBService.selectStStationBList(stStationB);
        return getDataTable(list);
    }

    /**
     * 查询测站信息登记列表
     */
    @RequiresPermissions("datam:StStationB:list")
    @GetMapping("/AllListWater")
    public TableDataInfo AllListWater(StStationB stStationB)
    {
        List<StStationB> list = stStationBService.selectStStationBListByWaterType(stStationB);
        return getDataTable(list);
    }

    /**
     * 查询测站信息登记列表
     */
    @RequiresPermissions("datam:StStationB:list")
    @GetMapping("/selStStationBByType")
    public TableDataInfo selStStationBByType(String[] statTypes)
    {
        List<StStationB> list = stStationBService.selStStationBByType(statTypes);
        return getDataTable(list);
    }

    /**
     * 查询测站信息登记列表
     */
    @RequiresPermissions("datam:StStationB:list")
    @GetMapping("/ListWaterType")
    public TableDataInfo ListWaterType2(StStationB stStationB)
    {
        List<StStationB> list = stStationBService.selectStStationBListByWaterType(stStationB);
        return getDataTable(list);
    }

    /**
     * 查询测站信息登记列表
     */
    @RequiresPermissions("datam:StStationB:list")
    @GetMapping("/AllListImage")
    public TableDataInfo AllListImage(StStationB stStationB)
    {
        List<StStationB> list = stStationBService.selectStStationBListByWaterType(stStationB);
        return getDataTable(list);
    }

    /**
     * 导出测站信息登记列表
     */
    @RequiresPermissions("datam:StStationB:export")
    @Log(title = "测站信息登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StStationB stStationB)
    {
        List<StStationB> list = stStationBService.selectStStationBList(stStationB);
        ExcelUtil<StStationB> util = new ExcelUtil<StStationB>(StStationB.class);
        util.exportExcel(response, list, "测站信息登记数据");
    }

    /**
     * 获取测站信息登记详细信息
     */
    @RequiresPermissions("datam:StStationB:query")
    @GetMapping(value = "/{statCd}")
    public AjaxResult getInfo(@PathVariable("statCd") String statCd)
    {
        return success(stStationBService.selectStStationBByStatCd(statCd));
    }

    /**
     * 新增测站信息登记
     */
    @RequiresPermissions("datam:StStationB:add")
    @Log(title = "测站信息登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StStationB stStationB)
    {
        if (stStationB.getCrossCd()==null){
            return error("请选择渠道断面");
        }
        return toAjax(stStationBService.insertStStationB(stStationB));
    }

    /**
     * 修改测站信息登记
     */
    @RequiresPermissions("datam:StStationB:edit")
    @Log(title = "测站信息登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StStationB stStationB)
    {
        return toAjax(stStationBService.updateStStationB(stStationB));
    }

    /**
     * 删除测站信息登记
     */
    @RequiresPermissions("datam:StStationB:remove")
    @Log(title = "测站信息登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statCds}")
    public AjaxResult remove(@PathVariable String[] statCds)
    {
        return toAjax(stStationBService.deleteStStationBByStatCds(statCds));
    }
}
